<template>
    <section>
        <el-col :span="24">
            <el-form inline>
                <el-form-item>
                    <el-input size="small" v-model.trim="form.processing_code" placeholder="加工单" clearable></el-input>
                </el-form-item>
                <el-form-item>
                    <el-input size="small" v-model.trim="form.type_no" placeholder="款号" clearable></el-input>
                </el-form-item>
                <el-form-item>
                    <el-input size="small" v-model.trim="form.jy_withdrawal_number" placeholder="采退返修单号" clearable></el-input>
                </el-form-item>
                <el-form-item>
                    <el-select v-model="form.groups" size="small" style="width: 100px" placeholder="业务类型" clearable>
                        <el-option v-for="(item, index) in groups" :key="index" :value="item.value" :label="item.label"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-select size="small" v-model="form.k_status" placeholder="是否抵扣" style="width: 100px" clearable>
                        <el-option :value=0 label="未抵扣"></el-option>
                        <el-option :value=2 label="已抵扣"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" class="el-icon-search" @click="searchBtn" size="small" :loading="btnLoading">查询</el-button>
                </el-form-item>
            </el-form>
        </el-col>
        <el-col :span="24">
            <el-table :data="data" style="width: 100%" :max-height="tableHeight" v-loading="loading" size="mini">
                <el-table-column label="生产加工单号" prop="processing_code" width="130"></el-table-column>
                <el-table-column label="采退返修单号" prop="jy_withdrawal_number" width="150"></el-table-column>
                <el-table-column label="款号" prop="type_no" width="140"></el-table-column>
                <el-table-column label="工厂" prop="factory_name" show-overflow-tooltip></el-table-column>
                <el-table-column label="成衣成本加价总价(大货)" prop="contract_machining_price" width="150"></el-table-column>
                <el-table-column label="成衣成本加价总价(实付)" prop="pay_machining_price" width="150"></el-table-column>
                <el-table-column label="数量" align="center" prop="num">
                    <template slot-scope="{ row }">
                        <div style="color:#f56c6c">-{{ row.num }}</div>
                    </template>
                </el-table-column>
                <el-table-column label="退款金额" prop="amount" width="100">
                    <template slot-scope="{ row }">
                        <div style="color: #f56c6c">-{{ row.amount }}</div>
                    </template>
                </el-table-column>
                <el-table-column label="业务类型" align="center" prop="groups" width="80">
                    <template slot-scope="{ row }">
                        <el-tag size="mini" v-if="row.groups==1">返厂维修</el-tag>
                        <el-tag size="mini" v-else type="warning">采购退货</el-tag>
                    </template>
                </el-table-column>
                <el-table-column label="状态" align="center" prop="k_status">
                    <template slot-scope="{ row }">
                        <el-tag size="mini" type="success" v-if="row.k_status==2">已抵扣</el-tag>
                        <el-tag size="mini" type="info" v-else>未抵扣</el-tag>
                    </template>
                </el-table-column>
                <el-table-column label="创建时间" prop="createtime" width="150"></el-table-column>
            </el-table>
            <!--翻页栏-->
            <div style="margin-top: 4px;overflow: hidden;float: right;">
                <Page :total="total" :current="page" :page-size="limit" show-total @on-change="pageChange"></Page>
            </div>
        </el-col>
    </section>
</template>

<script>

import {repairList} from "@/api/soa/repair";

export default {
    name: "soa_cy_repair",
    data() {
        return {
            tableHeight: window.innerHeight - 210,
            selectIndex: 0,
            btnLoading: false,
            loading: false,
            page: 1,
            limit: 20,
            total: 0,
            data: [],
            user: {},
            nodeActions: [],

            form: {processing_code: "", type_no: "", jy_withdrawal_number: "", k_status: "", groups: ""},
            groups:[{value:0, label:"采购退货"},{value:1, label:"返厂维修"}],

        }
    },
    created() {
        this.user = this.$store.getters.user;
        this.nodeActions = this.user.node_actions[this.$route.meta.id] ? this.user.node_actions[this.$route.meta.id] : [];
    },
    methods: {
        //搜索按钮
        searchBtn() {
            this.page = 1;
            this.getData();
        },
        //翻页
        pageChange(page) {
            this.page = page;
            this.getData();
        },
        //获取数据
        getData() {
            let param = {
                page: this.page,
                limit: this.limit
            };
            param = Object.assign(param, this.form);
            this.loading = true;
            repairList(param).then((res) => {
                this.loading = false;
                this.total = res.data.total;
                this.data = res.data.data;
            }).catch(() => {
                this.loading = false;
            });
        },
    },
    mounted() {
        this.searchBtn();
    }
}
</script>

<style scoped>

</style>
